package com.gzwanchuang.lszg.web.inteface;

import android.os.Handler;
import android.os.Message;
import android.util.Log;
import android.webkit.JavascriptInterface;

import com.gzwanchuang.lszg.utils.LogUtil;
import com.gzwanchuang.lszg.web.ui.WebViewActivity;

public class JavaScriptInterface {

    private Handler handler;

    public JavaScriptInterface(Handler handler) {
        this.handler = handler;
    }

    @JavascriptInterface
    public void back() {
        Message message = new Message();
        message.what = WebViewActivity.BACK;
        handler.sendMessage(message);
    }



    @JavascriptInterface
    public void goLogin(){
        LogUtil.e("mango","H5吊起登录");
        Message message = new Message();
        message.what = WebViewActivity.LOGIN;
        handler.sendMessage(message);
    }


    @JavascriptInterface
    public void goToCapture(){ //跳转实名认证方法
        Log.e("mango", "goToCapture: ");
        Message message = new Message();
        message.what = WebViewActivity.GOTOCAPTURE;
        message.obj = "goToCapture";
        handler.sendMessage(message);
    }


    @JavascriptInterface
    public void logout(){ //
        Log.e("mango", "goToCardPrint: ");
        Message message = new Message();
        message.what = WebViewActivity.LOGIN_OUT;
        handler.sendMessage(message);
    }




    @JavascriptInterface
    public void goToMain(){
        Message message = new Message();
        message.what = WebViewActivity.GOTOMAIN;
        handler.sendMessage(message);
    }

    @JavascriptInterface
    public void uploadFile(String methodName){
        Message message = new Message();
        message.what = WebViewActivity.TAKEPHOTO;
        message.obj = methodName;
        handler.sendMessage(message);
    }

    @JavascriptInterface
    public void jumpTo(String url){
        Message message = new Message();
        message.what = WebViewActivity.JUMPTO;
        message.obj = url;
        handler.sendMessage(message);
    }

    @JavascriptInterface
    public void takePhotoIDCard(String params){ //跳转实名认证方法
        Message message = new Message();
        message.what = WebViewActivity.TAKEPHOTOIDCARD;
        message.obj = params;
        handler.sendMessage(message);
    }



}